-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
Deduplicated float tests and unified in floats/mod.rs #148206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Any update @bjorn3 ? |
|
CI is still failing. |
ok let me fix . |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Some changes occurred in compiler/rustc_codegen_cranelift cc @bjorn3 |
b802b19 to
abd73fd
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| let inf: Float = Float::INFINITY; | ||
| let neg_inf: Float = Float::NEG_INFINITY; | ||
| assert_biteq!((10.0 as Float).log(10.0), 1.0); | ||
| assert_approx_eq!((2.3 as Float).log(3.5), 0.664858, Float::LOG_APPROX); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test here for f128 will fail because the precision is much higher, if you look at the original test, the expected value is much more precise than what you have written:
assert_approx_eq!(2.3f128.log(3.5), 0.66485771361478710036766645911922010272, TOL);When testing higher precision floats, you need much more precise expected values or the tests will fail, as they do now. In Miri, this is even more strict.
If you look at the source of f16 constants, they use much more digits after the decimal point than needed:
pub const PI: f16 = 3.14159265358979323846264338327950288_f16;So you should probably do that as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay it makes sense . Thanks
|
Thank you for the final cleanup here. Until CI is fixed, |
|
Reminder, once the PR becomes ready for a review, use |
Will finish this as soon as possible . A bit busy these days. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
0f27f23 to
507fb72
Compare
Deduplicated float tests and unified in floats/mod.rs try-job: aarch64-apple try-job: x86_64-mingw-1
| // FIXME(f128): f128 math operations need f128 math symbols, which currently aren't always | ||
| // filled in by compiler-builtins. The only libc that provides these currently is glibc. | ||
| let has_reliable_f128_math = has_reliable_f16_f128 && sess.target.env == Env::Gnu; | ||
|
|
||
| TargetConfig { | ||
| target_features, | ||
| unstable_target_features, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bjorn3 does this look okay?
This comment has been minimized.
This comment has been minimized.
|
💔 Test for fc578bb failed: CI. Failed job:
|
|
In the logs it appears the MinGW math library has a bug in tgamma implementation. |
| assert!(Float::NAN.gamma().is_nan()); | ||
| assert!(Float::NEG_INFINITY.gamma().is_nan()); | ||
| assert_biteq!(Float::INFINITY.gamma(), Float::INFINITY); | ||
| assert_biteq!(flt(1760.9).gamma(), Float::INFINITY); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason the failure started showing up is that this used to be 171.71 for all float types, and 1760.9 only for f128. You should change this to:
// FIXME: there is a bug in the MinGW gamma implementation that causes this to
// return NaN. https://sourceforge.net/p/mingw-w64/bugs/517/
if !cfg!(all(target_os = "windows", target_env = "gnu", not(target_abi = "llvm"))) {
assert_biteq!(flt(1760.9).gamma(), Float::INFINITY);
}
if Float::Int::BITS <= 64 {
assert_biteq!(flt(1760.9).gamma(), Float::INFINITY);
}cae80de to
fa47b93
Compare
|
Don't squash the cranelift patch, keep that separate. Having good notes in the blame and history is important. The rest can (an should) remain squashed, though. I made a typo in the snip I posted, it should be // FIXME: there is a bug in the MinGW gamma implementation that causes this to
// return NaN. https://sourceforge.net/p/mingw-w64/bugs/517/
if !cfg!(all(target_os = "windows", target_env = "gnu", not(target_abi = "llvm"))) {
assert_biteq!(flt(1760.9).gamma(), Float::INFINITY);
}
if Float::Int::BITS <= 64 {
assert_biteq!(flt(171.71).gamma(), Float::INFINITY);
}(second assert has 171.71 as the input, not the same thing twice) |
fa47b93 to
dc9db23
Compare
|
And I thought why not to just use && and make it a single check. That looked a bit weird I should have ask but no worries I will update it now . |
Just to be clear here u talking about the disable math tests patch or the patch that you made in cranelift lib.rs about not to squash? |
This comment has been minimized.
This comment has been minimized.
The commit I pushed 451738f, since it's kind of separate from the rest here. I can help with the history if needed since git can be tricky. That's a rather annoying error. I guess maybe add |
| #[doc(hidden)] | ||
| trait TestableFloat: Sized { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#[doc(hidden)] shouldn't be needed, it's a private trait
dc9db23 to
92c9baf
Compare
Okay! adding a constant |
|
@bors try jobs=aarch64-apple,x86_64-mingw-1 |
This comment has been minimized.
This comment has been minimized.
Deduplicated float tests and unified in floats/mod.rs try-job: aarch64-apple try-job: x86_64-mingw-1
92c9baf to
063a9de
Compare
|
Try build cancelled. Cancelled workflows: |
This comment has been minimized.
This comment has been minimized.
Deduplicated float tests and unified in floats/mod.rs try-job: aarch64-apple try-job: x86_64-mingw-1
063a9de to
eef1838
Compare
|
The job Click to see the possible cause of the failure (guessed by this bot) |
|
💔 Test for 7250dcf failed: CI. Failed job:
|
|
@tgross35 what you suggest for these macOS linker errors? |
In this PR Float tests are deduplicated and are unified in floats/mod.rs, as discussed in #141726.
The moved float tests are:
-> test_powf
-> test_exp
-> test_exp2
-> test_ln
-> test_log_generic
-> test_log2
-> test_log10
-> test_asinh
-> test_acosh
-> test_atanh
-> test_gamma
-> test_ln_gamma
Closes: #141726
r? tgross35